package flex.persistence.criteria {
	import mx.utils.ArrayUtil;
	import mx.utils.StringUtil;
	public class JoinType {
		
		protected static var localInstantiation:Boolean = false;		
		private static var _INNER:JoinType; 	
		
		public static function get INNER():JoinType {
			if(!_INNER) { 
				localInstantiation = true;
				_INNER = new JoinType("inner");
				localInstantiation = false;
			}
			return _INNER;
		} 
		
		private static var _LEFT:JoinType; 
		
		public static function get LEFT():JoinType {
			if(!_LEFT) { 
				localInstantiation = true;
				_LEFT = new JoinType("left");
				localInstantiation = false;
			}
			return _LEFT;
		} 
		
		private static var _RIGHT :JoinType; 
		public static function get RIGHT ():JoinType {
			if(!_RIGHT ) { 
				localInstantiation = true;
				_RIGHT  = new JoinType("right");
				localInstantiation = false;
			}
			return _RIGHT ;
		} 

		public static function valueOf(name:String):JoinType {
			for each(var val:JoinType in values()) {
				if(val.name.toUpperCase() == name.toUpperCase()) return val;
			}
			return null;
		}
		
		public static function values():Array {
			return [LEFT, INNER, RIGHT];
		}
		   
		protected var name:String;
		public function JoinType(name:String) {
			if(!localInstantiation) throw Error("Private constructor");
			this.name = name;
		}
		
		public function toString():String {
			return this.name;
		}
		
		public function equals(obj:Object):Boolean {
			return this.name == obj.name;
		}
	}
}